perm filename T2[E,ALS] blob sn#180881 filedate 1975-10-13 generic text, type T, neo UTF8
;E -- DISPLAY EDITOR FOR STANFORD
;Written by Frederick H.G. Wright II 
;with modifications by D. Poole, Art Samuel, and Stan Kugell.
;The Essay program was contracted by John Mccarthy and written by Stan Kugell

PRINTS /Type 0 to get ETV, 1 to get ESSAY, then <CTRL><META><LF>./
ESSFLG←←.INSER TTY:

IFE ESSFLG<TITLE ETV -- DISPLAY EDITOR FOR STANFORD↔SUBTTL FREDERICK H.G. WRIGHT II
PRINTS /       You are assembling ETV, the Stanford Display Editor
/
PRINTS⊗	July 6  E.49(p545)	July 17 E.50(P551)	July 25 E.51(P512)
	July 27 E.52(P554)	July 30 E.53(P554)	July 31 E.54(T16)
	Aug. 2  E.55(P558)	Aug. 5	E.56(P558)	Aug.11	E.57(P560)
	Aug 14	E.58(T27)	Aug.18	E.59(P567)	Aug. 20 E.60(P567)
		E.61(P570)	Sept.17	E.62(P575)	Sept.23	E.63(p581)
	Sep.30	E.64(p581)	OCT. 9	E.65
see E.52 for details as to changes in earlier versions
Note that E.52 and all that follow use and requires new PTL7W9 on system 7.01 T.
 If backing up to system before this one must use E.51.
E.59 ME fixes to CRLF'S and to improve operations on TTY's
see E.59 for changes from E.52 through E.59
E.60 fixed bug causing \ and * commands to start search from wrong column.
E.61 ALLACT mode used: type-ahead for line-editor wins; BS now works like VT.
 XSNKOFF,XSNKON,XNWFILE flushed.  αβ<form> means αβ-<form>.  0W, 0L do half window.
E.62 ∂ command for handling messages.  Improvement in positioning line after a
 search.  ACs A,B preserved for dispatch routine by FOUND.  File switching after
 R E;<file> startup doesn't cause TMPCOR file to be written out.
E.63 0∃ bug fixed.  αβFaaaαβ\bbb<cr> made illegal in attach mode.
 RENAME to update time/date written is no longer done by E (system does it).
 ++++ changed to .... at edge of window.
 ε and λ fixed to not close current file if illegal file number given.
E.64 Fix to SETJMP to avoid glitching screen just because BOTWIN is -1.
 Debugged additions to LINCNT and to TELLME code by ALS.
 Fixed substitution bug that caused list of lines to be clobbered.
 XBURP command to burp null records from a single page.
E.65 XDEFINE and Y macro- defining and calling commands.
 αV now just redraws screen.  αβV erases screen then redraws.
 DETACHing and then ATTACHing an E job now works a little better.
E.66 BUG in JUST with periods at the end of a line fixed.(UP on Oct. 9)
 Fixed LOADMT and EDIT to not do PTLOAD for IMLACs or other non-displays.
 Fixed FRD not to call EPSIL4 if no name given when coming from XRUN or XRSYS.
 Flushed references to PTL assembly switch (used PTLOAD instead of PTL7W9 if PTL=0).
 Fixed character count bug in CENTER and INDENT.
⊗>

IFN ESSFLG<TITLE ESSAY
PRINTS /       You are assembling Essay.
/>
DEFINE ESSAY <IFN ESSFLG>
DEFINE NOESS <IFE ESSFLG>

COMMENT ⊗ TO PUT UP A NEW E WITH AN UPPER SEGMENT, USE THE COMMANDS:

.LOA %SE%1<%2V%1B	;LOADS WITH SYMBOLS AND NNRAID IN THE UPPER SEGMENT
.S 137			;RENAMES UPPER, WRITE PROTECTS AND SETS ITS PROTECTION CONSTANT
.SSAVE SYS E		;BE SURE TO SSave (to keep the UPPER SEGMENT around)

DATA STRUCTURE.
	A page  of text is  represented in memory  as a theaded  list of
items  each representing a  single line of  the text. Each  item in this
representation contains four  words of header  information, the text  of
the line in question and one trailer word.
	The first header word contains a TXTCOD, which for ordinary text
is a 2 in the left half and the total number of words in the right half. 
This word  is used by the free storage  management routines. It does not
seem to be used by the text manipulation sections of the code.  The word
count is duplicated in  the trailer word which is also  used only by the
free storage routines. 
	The  second  header  word is  a  pointer word.    It  contains a
backward pointer  in  the left  half  pointing to  the location  of  the
pointer  word of  the previous  item  and in  the right  half  a forward
pointer to  the location  of the  pointer  word of  the next  item.  The
location of the pointer word for the first item is contained in the word
at  PAGE and  the  backward pointer  for the  first item points  back to
PAGE. The last item on the page points to the word BOTSTR and  this word
points back to this last item and forward to itself.  When in the ATTACH
mode,   the  location  ATTBUF points  to the pointer  word of  the first
attached line and back to the pointer word of the last attached line.
	The third word contains  flag bits in the left  half identifying
the type  of the line and two  9-bit bytes in the right  half. Flag bits
which have been identified are:
	400000	 the line is a page mark.
	200000	 the line is ARRLIN (CURRENT to which the arrow points).
	100000	 the line is WINLIN (the first line on the window).
	040000   the line is an Essay reference (for the ESSAY version).
The  first byte  in  the right  half  contains the  total  count of  the
characters as the line is stored on the disk, where a TAB symbol counts
1 and the terminating CR and LF are counted.
The  second byte  contains  the  count of  the  characters as  they  are
displayed where a TAB is counted as the number of spaces it produces and
the terminating CR and LF are not counted. 

	The fourth word is the serial number of the line as kept in the
core. This number is changed every time that a change is made to the line
so this number then bears no relationship to the position of the line on
the page.

	The text occupies an integral number of words and is  padded out
with nulls.
	The trailer  word contains the count  of the total words  in the
item,   including  header   and  trailer  words.   This  duplicates  the
information in the right half of the first header word.

       TABs are handled in a pecular way. When a TAB occurs it is stored
as  a TAB and  this is  followed by as  many spaces  as the TAB  in fact
produces in the text and then by a terminating TAB.

       end of comment ⊗

NOLIT

;Register	Most common usage

F←0		;Flag bits
A←1		;Argument value
B←2		;CONTROL and META bits as stripped from command character.
C←3		;Character
D←4		;Dispatch table entry
E←5		;Table location.
G←6
H←7
I←10
DSP←11		;Dispatch table location (CTAB most of the time).
Q←14
T←15
TT←16
P←17		;Always reserved as PDL pointer.

DEFINE STOPJ
	{PUSHJ P,STOPJC	
	}	
;Used to replace JRST 4,. and other fatal halts to inform ALS of trouble
;STOPJ USED FOR JRST 4,. terminating with a JRST 4,. as usual
;STOPC used for JRST 4,. WHEN ATTEMPT IS MADE TO CONTINUE

IFNDEF PURESW<PURESW←←1>	;DEFAULT TO SHARABLE PURE UPPER SEGMENT
IFNDEF DEBSW<DEBSW←←1>
IFNDEF BOOKMD<BOOKMD←←1>
;BOOKMD NON-ZERO PERMITS /B MODE FOR READING BOOKS.  0 DISABLES /B MODE.

COPNUM←←3	;LOG OF # K OF CORE FOR TEMP COPY BUFFER
SRSIZ←←40	;SIZE OF SEARCH STRING BUFFER
LPDL←←69
DPYBSZ←←=660*2

DSKI←←1
DSKO←←2
DSKSP←←4	;Used for spooling file
DSKCH←←5	;Used to write into bug file TELLME.001[E,ALS] , .002 etc.
SWP←←3
IFN BOOKMD, {
RPGO←←4		;CHANNEL USED TO WRITE OUT .BKP FILE IN BKPSW MODE
};END BOOKMD

...←←0

;Type of display (kept in cell called DPY)
$TTY ←← 0	;Teletype kludge
$DD  ←←	1	;Datadisk video type display
$III ←←	2	;III Vector type display
IFNDEF MACDWP<MACDWP←←0>	;Disable DWP's macro-implementing code.
;RIGHT HALF FLAGS
REDNLY←←1	;READ ONLY MODE
COPY←←2		;NEED TO DO COPY (← OR →)
DIROK←←4	;HAVE COMPLETE DIR
UPDTXT←←10	;LINE 1 CHANGED - UPDATE DIR AT WRPAGE
WRITE←←20	;SOMETHING CHANGED - NEED TO WRITE IT
EOF←←40		;INPUT EOF DETECTED - DO ANOTHER LOOKUP (LOSING SYSTEM!)
EDDIR←←100	;EDITING THE DIRECTORY PAGE
ARG←←200	;ARG WAS TYPED TO COMMAND
DSPSCR←←400	;REDISPLAY SCREEN
DSPALL←←1000	;REDISPLAY WHOLE SCREEN
FILLUZ←←2000	;EDITING NONSTANDARD FORMAT FILE
REL←←4000	;RELATIVE ARG (+ OR -)
NEG←←10000	;NEGATIVE ARG
EDITM←←20000	;DISPATCH IS FROM LINE EDIT
EDBRK←←40000	;(WITH EDITM) COMMAND TYPED IN MIDDLE OF LINE
XPAGE←←100000	;WILL EXPAND FILE FOR PAGE
UPDIR←←200000	;NON-TEXT CHANGE TO DIR
ATTMOD←←400000	;IN ATTACH MODE

;LEFT HALF FLAGS
ENTRD←←1	;EDIT FILE HAS BEEN ENTERED
CLRBF←←2	;CLEAR OBUF AFTER OUTPUT
NOSHUF←←4	;DON'T SHUFFLE FREE STORAGE
NOCHK←←10	;DON'T TRY TO CORE DOWN
OFFEND←←20	;ARROW ON LINE N+1
NULLIN←←40	;CURRENT LINE IS EMPTY
ARRPG←←100	;ARROW POG IS SELECTED
TF1←←200	;TEMP FLAG
PMLIN←←400	;CURRENT LINE IS PAGE MARK
OKF←←1000	;SHOULD TYPE "OK"
	;New flags added by ALS.
ALIN←←2000		;ALINE FLAG
INDEN←←4000		;INDENT FLAG
CEN←←10000		;CENTER FLAG
JOINF←←20000		;JOIN FLAG
ZATT←←40000		;To save ATTACH on a Z-EPSIL command.
LINSM←←100000		;LINE INSERT MODE
;	200000
NGPUSE←←400000		;Network Graphic User
;CHARACTER TABLE FLAGS
NSPEC←←400000	;STANDARD SPECIAL CHAR (NULL OR RUBOUT) - MUST BE SIGN
FSPC←200000	;FILE NAME DELIMITER
LSPC←←100000	;SPECIAL CHAR IN LINE
NUMF←←40000	;DIGIT
DSPC←←20000	;SPECIAL DIR CHAR
LETF←←10000	;LETTER - WITH LT2F => LOWER CASE
LT2F←←4000	;ALONE => $%._
SSP1←←2000	;TYPE 1 SPECIAL SEARCH STRING CHAR
SSP2←←1000	;  "  2  " ...
EDOK←←40	;RIGHTMOST OF 4 BITS (SHIFT BY CONTROL BITS) FOR LINE EDITOR LEGALITY

;COMMAND DISPATCH FLAGS
NOEDIT←←200000	;DISPATCH DIRECTLY FROM LINE EDIT WITHOUT REPLACING LINE
DOEDIT←←100000	;REPLACE LINE BEFORE DISPATCHING FROM LINE EDIT
		;IF NEITHER OF THE ABOVE, RE-EDIT LINE AT SAME CURSOR POS (CHAR IS NO-OP)
NOATT←←40000	;ILLEGAL IN ATTACH MODE
NORDO←←20000	;ILLEGAL IF READ-ONLY
;10000		;USER MODE BIT MUST BE UNUSED
SACMD←←4000	;USES SEARCH ARG
SSCMD←←2000	;SPECIAL ACTION WHEN ENTERED FROM SEARCH
MSGCMD←←1000	;SPECIAL ACTION WHEN ENTERED FROM MSG COMMAND (PARTIAL SIGN)

LPDESC←←3	;# EXTRA WDS DIR ENTRY
DPBIT←←400000	;DIRPT ENTRY
D1BIT←←200000	;DIRP1 ENTRY
RPMASK←←77	;MASK FOR RELATIVE PAGE # FIELD
RPBYTE←←<220600,,>	;BYTE PNTR FOR ABOVE

LLDESC←←3		;# EXTRA WDS TEXT LINE
PMARK←←400000		;THIS LINE IS A PAGE MARK
ARRBIT←←200000		;LINE IS ARRLIN
WINBIT←←100000		;LINE IS WINLIN
PTRBIT←←040000		;LINE IS COMMENT OR REFERENCE POINTER

LOKBIT←←200000	;LOCKS DOWN FS BLOCK (CAN'T BE SHUFFLED)

MAXLIN←←=42
ATTMAX←←8

;Flags used in left half of D in FRD and related file-specification code
FRDNAM←←40		;A new name was typed
FRDEXT←←100		;An extension was typed
FRDPRJ←←200		;A project name was typed
FRDPRN←←400		;A programmer name was typed
FRDDEV←←1000		;A device was specified
FRDTMP←←200000		;TMPCOR has been read and may have to be overruled
;FRDRUN must be sign bit.
FRDRUN←←400000		;Used by XRUN command to get filename without switches
;BITS FOR GETLIN, SETACT, DEVCHR.  S 137 CODE.  SORRYU FATALU

DD←←20000	;RUNNING ON DATA DISK
III←←400000	;  "	 "  III (BITS FROM GETLIN)
PTY←←4000	;  "     "  PTY
IMLIN←←2000	;  "     "  IMLAC
SUPCCR←←2	;BREAK TABLE BIT TO SUPPRESS CTRL1-CR HACK
EMODE←←10	;Break table bit to place 400 after last char when activating
ALLACT←40	;Break table bit to make all ctrl chars and BS active unless re-editing
DVDSK←←200000	;DISK BIT FROM DEVCHR
MININT←←23	;LOWEST INT BIT #
ADRSIZ←←17	;# BITS NEEDED TO ADDRESS PERMANENT CODE

ZZ←←.
LOC 137
IFN PURESW,<
	JRST [	NOESS,<	MOVSI 'E  '>	;UPPER NAME ONCE SYSTEMIFIED
		ESSAY,<	MOVE ['ESSAY ']>
		SETNM2
		JRST 4,137
		MOVE P,[-LPDL+1,,PDL]	;Temp stack for checksum compute
		PUSHJ P,CHKUP		;Check upper segment before setpro
		MOVEM T,CHKSUM
		MOVNI 1
		SETUWP
		JRST 4,137
		MOVSI 155000
		SETPRO
		JRST 4,137
		CALLI 12]
>

IFG DEBSW-PURESW,<
	JRST [	JSP E,PURINI
		CALLI 12]
>

ORG ZZ

FOR @! FOO IN(SORRY,FATAL)
{DEFINE FOO(X)
{	FOO!U [ASCIZ /X/]}
}
;GETCHR GETCH1 GETCH2 FSFIX TSTSHF CW LEG UUOS XOPDEF PURE IMPURE

DEFINE GETCHR(X)
{ILDB C,INPNT
SKIPGE X,CTAB(C)
XCT @CTAB(C)}

DEFINE GETCH1(X)
{ILDB C,INPNT
TDNE X,CTAB(C)
XCT @CTAB(C)}

DEFINE GETCH2(X,Y)
{	ILDB C,Y
	TDNE X,CTAB(C)
	XCT @CTAB(C)}

DEFINE FSFIX(X,Y)
{	HRRI Y,(X)
	SUB Y,FSEND
LEG	MOVEM Y,@FSEND
LEG	HRRZM Y,-1(X)
	HRRZM X,FSEND}

IFN DEBSW{DEFINE TSTSHF
{	SKIPE SHFMOD
	PUSHJ P,MOVIT}}
IFE DEBSW{DEFINE TSTSHF{}}

DEFINE CW(C1,D1,C2,D2,C3,D3){BYTE(8)D1,D2,D3(3)C1,C2,C3,4}

;THESE MACROS MAKE A LINKED LIST AROUND AND THROUGH
;PURE AND UNPURE PARTS FOR CHECKSUMING THE PURE PARTS
;AN ERROR WILL RESULT IF THE SAME MACRO IS CALLED
;TWICE WITHOUT CALLING THE OTHER MACRO.
%SEG←←0
IFE PURESW{
	DEFINE PURE{IFN %SEG{!}	%SEG←←1	PURBEG←←.}
	DEFINE IMPURE{IFE %SEG{!}	%SEG←←0
		PURBEG,,PURLK2↔PURLK2←←.-1
		PURBEG,,PURLNK↔PURLNK←←.-1}
PURLNK←←PURLK2←←0}


;THESE MACROS SET RELOCATION TO THE PROPER SEGMENT FOR PURE OR UNPURE CODE
;AN ERROR MESSAGE WILL RESULT IF THE SAME MACRO IS CALLED TWICE WITHOUT
;CALLING THE OTHER MACRO.
IFN PURESW{
	TWOSEG
	RELOC 400000
	RELOC
	DEFINE PURE{IFN %SEG{!}	%SEG←←1	RELOC}
	DEFINE IMPURE{IFE %SEG{!}	%SEG←←0	RELOC}}


;THIS MACRO SHOULD PRECEDE A LINE OF CODE WHICH CAN
;GENERATE A LEGAL ILL MEM REF.
LEGNUM←←0
DEFINE LEG{FOR @! X←LEGNUM,LEGNUM{LEG!X←←.}	LEGNUM←←LEGNUM+1
}


DEFINE UUOS{FOR @! X IN(TYPCHR,TYPDEC,TYPOCT,SORRYU,FATALU)}

ZZ←←0
UUOS{ZZ←←ZZ+1
OPDEF X[ZZ⊗33]
}

NUUOS←←ZZ+1

EXTERN JOBREL,JOBFF,JOBAPR,JOBTPC,JOBDDT,JOBREN,JOBOPC,JOBCNI
PURE
;BEG BEGSYS BEGACT BEGRPT BEGDBG

IFN DEBSW,<JRST BEGDBG>
	JRST BEGRPT
BEG:	JRST BEG0				;RUN OR ET COMMAND
	JRST BEGRPG				;RPG START. AC'S CONTAIN PARAMS
	MOVEM 16,EPDL				;SYSTEM AXXCOM START
	MOVEM 17,EPDL2				;17[SIXBIT COMMAND, 16[ASCII DELIM
	JSP P,INIT				;INITIALIZE
	MOVE T,EPDL2				;GET COMMAND NAME
	MOVEM T,SYSCMD				;STOW IT
	MOVE A,[440700,,BUF]			;INITIAL BYTE POINTER
	MOVE C,EPDL				;INITIAL CHARACTER IN "SCAN"
;	PUSHJ P,TYIT
;	JRST BEGACT
	INWAIT
	HRLOI T,377777				;SET T INFINITE
	PUSHJ P,RSCN4A				;SCAN REMAINER OF COMMAND FOR ARGS
BEGSYS:	LDB C,[301400,,SYSCMD]			;GET 2 CHARACTERS OF COMMAND NAME
	PUSHJ P,SYSCCK				;DO WE KNOW THEM
	JRST BEG1				;YES. NOW WE READ FILE NAME FROM TTY
	JRST BEG0				;DONT UNDERSTAND COMMAND. RESCAN.

BEGACT:	MOVE T,[440700,,[ASCIZ /
/]]
	MOVEM T,TYIPNT
	JRST BEGSYS

BEGRPT:	JSP P,INIT			;INITIALIZE
	PUSHJ P,TMPRED			;TRY TO READ TMPCORE FILE
	JRST BEG0A
	PUSH P,TYIPNT			;SAVE POINTER TO ARGS
	MOVEM G,TYIPNT			;POINT TO COMMAND
	PUSHJ P,GETNAM			;AND READ IT
	MOVEM A,SYSCMD
	POP P,TYIPNT			;NOW POINT TO ARGS AGAIN
	JRST BEGSYS			;AND LOOK LIKE AXXCOM STARTUP

IFN DEBSW,<
BEGDBG:	JSP P,INIT			;HERE FOR DEBUGGING. INITIALIZE
	INWAIT				;WAIT FOR SOMETHING TO BE TYPED
	HRLOI T,377777			;SET CHARACTER COUNT TO INFINITE
	PUSHJ P,RSCAN0			;READ COMMAND, AVOID RESCAN
	JRST BEG0A			;ACT NORMAL
>